package com.maple.camera1;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

/**
 * 人脸框View
 * Created by maple on 2019/3/26 17:30
 * E-Mail Address：740917401@qq.com
 */
public class CameraDetectView extends View {
    public CameraDetectView(Context context) {
        super(context);
    }

    public CameraDetectView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public CameraDetectView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    int left ;
    int right ;
    int top ;
    int bottom ;
    int color;

    public void setRectAndColor(int left,int top,int right,int bottom,int color){
        this.left=left;
        this.right=right;
        this.top=top;
        this.bottom=bottom;
        this.color=color;
    }


    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint paint=new Paint();
        paint.setColor(color);//颜色
        paint.setStrokeWidth(4);//边框粗细
        paint.setStyle(Paint.Style.STROKE);//边框
        Rect rect = new Rect();
        rect.set(left, top, right, bottom);
//        /**绘制之前先对画布进行翻转**/
//        canvas.scale(-1, 1, getWidth() / 2, getHeight() / 2);
        canvas.drawRect(rect,paint);
    }


}
